package forg;

import robocode.AdvancedRobot;
import robocode.ScannedRobotEvent;
import robocode.StatusEvent;

import java.awt.*;
import java.awt.geom.Point2D;

/**
 * author : lianhui.klh
 * time   : 2017-11-01 20:04
 */
public class FuckAll extends AdvancedRobot {

    public void run() {

        setBodyColor(Color.BLACK);
        setScanColor(Color.BLUE);
        setRadarColor(Color.YELLOW);

        while (true) {

            //先扫一扫
            turnRadarRightRadians(Double.POSITIVE_INFINITY);
        }
    }

    @Override
    public void onScannedRobot(ScannedRobotEvent e) {

        double enemyAbsoluteBearing = getHeadingRadians() + e.getBearingRadians();
        Point2D enemyPoint =getPoint(new Point2D.Double(getX(), getY()),enemyAbsoluteBearing,e.getDistance());

    }

    @Override
    public void onStatus(StatusEvent e) {
        super.onStatus(e);
    }

    private Point2D getPoint(Point2D src,double angle,double distance){
        return new Point2D.Double(src.getX() + Math.sin(angle) * distance,
                src.getY() + Math.cos(angle) * distance);
    }
}
